#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]) {
	// printf("argc = %d\n", argc);
	if(argc != 2) {
		printf("input error!\n\tUsage:pandoctopdf sample.md\n");
		printf("it's just a simple binary, let me go");
		printf("if you want to change, source:http://git.oschina.net/xuie0000/tools-test");
		return;
	}
	int i;
	// for(i = 0; i < argc; i++){
	// printf("argv[%d] = %s\n", i, argv[i]);
	// }
	// system("ls");
	char *home_path = getenv("HOME");
	// printf("%s\n", home_path);
	char pandoc_cmd[1024] = {0};
	char pdf_name[1024] = {0};
	strncpy(pdf_name, argv[1], strlen(argv[1]) - 3);
	strcat(pdf_name, ".pdf");
	sprintf(pandoc_cmd, "pandoc -f markdown -s --latex-engine=xelatex --template=%s/.local/xelatexStyle.tex \"%s\" -o \"%s\"", home_path, argv[1], pdf_name);
	system(pandoc_cmd);

	return 0;
}